<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    ul {
      padding: 0;margin: 0;
      display: flex;
    }
    ul li {
      list-style: none;
      border: 1px solid #ccc;
      padding: 5px 10px;
      cursor: pointer;
    }
    .li_active{
      background-color: pink;
    }
    img{
      width: 350px;
      height: 300px;
      display: none;
    }
    .img_acitve{
      display: block;
    }
  </style>
</head>
<body>
  <div id="app">
    <!-- 声明式 -->
    <ul>
      <li @click="changeFlag(item.id)" :class="{li_active: item.id === flag}" v-for="item in list" :key="item.id">{{item.title}}</li>
    </ul>
    <img :class="{img_acitve: item.id === flag}" v-for="item in list" :key="item.id" :src="item.imgUrl" alt="">
  </div>
  <script src="./vue.js"></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        flag: 1,
        list: [
          { id: 1, title: 'xzmly', imgUrl: './imgs/xzmly.webp' },
          { id: 2, title: 'cls', imgUrl: './imgs/cls.webp' },
          { id: 3, title: 'bdyjy', imgUrl: './imgs/bdyjy.webp' },
        ]
      },
      methods: {
        changeFlag(id) {
          this.flag = id
        }
      }
    })
  </script>
</body>
</html>